package com.lvmama.rhino.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lvmama.rhino.entity.MonitorVO;
import com.lvmama.rhino.mapper.MonitorFailureApiMapper;
import com.lvmama.rhino.pojo.OptionData;
import com.lvmama.rhino.pojo.monitor.MonitorApi;
import com.lvmama.rhino.pojo.monitor.MonitorApiFailure;
import com.lvmama.rhino.service.MonitorFailureApiService;

@Service("monitorFailureApiService")
public class MonitorFailureApiServiceImpl implements MonitorFailureApiService{
    
    @Autowired
    private MonitorFailureApiMapper monitorFailureApiMapper;

    /**
     * 所有接口失败率占比
     * @param monitorVO
     * @return
     */
    @Override
    public List<OptionData> queryOptionDataList(MonitorVO monitorVO) {
        return monitorFailureApiMapper.queryOptionDataList(monitorVO);
    }

    /**
     * 分页查询失败接口信息
     * @param monitorVO
     * @return
     */
    @Override
    public PageInfo<MonitorApiFailure> queryMonitorFailureApiPage(MonitorVO monitorVO) {
        PageHelper.startPage(monitorVO.getPage(), monitorVO.getPageSize());
        List<MonitorApiFailure> monitorFailureApiList = monitorFailureApiMapper.queryMonitorFailureApiList(monitorVO);
        PageInfo<MonitorApiFailure> page = new PageInfo<MonitorApiFailure>(monitorFailureApiList);
        return page;
    }

    /**
     * 接口失败率版本分布
     * @param monitorVO
     * @return
     */
    @Override
    public List<MonitorApiFailure> queryMonitorFailureApiVersionList(MonitorVO monitorVO) {
        return monitorFailureApiMapper.queryMonitorFailureApiVersionList(monitorVO);
    }

    /**
     * 接口失败率运营商分布
     * @param monitorVO
     * @return
     */
    @Override
    public List<MonitorApiFailure> queryMonitorFailureApiOperatorsList(MonitorVO monitorVO) {
        return monitorFailureApiMapper.queryMonitorFailureApiOperatorsList(monitorVO);
    }

    /**
     * 接口失败率网络分布
     * @param monitorVO
     * @return
     */
    @Override
    public List<MonitorApiFailure> queryMonitorFailureApiNetworkTypeList(MonitorVO monitorVO) {
        return monitorFailureApiMapper.queryMonitorFailureApiNetworkTypeList(monitorVO);
    }

    /**
     * 接口失败率省份分布
     * @param monitorVO
     * @return
     */
    @Override
    public List<MonitorApiFailure> queryMonitorFailureApiProvinceList(MonitorVO monitorVO) {
        return monitorFailureApiMapper.queryMonitorFailureApiProvinceList(monitorVO);
    }

    /**
     * 单个接口失败率
     * @param monitorVO
     * @return
     */
    @Override
    public List<MonitorApiFailure> querySingleMonitorFailureApiList(MonitorVO monitorVO) {
        return monitorFailureApiMapper.querySingleMonitorFailureApiList(monitorVO);
    }

}
